package no.hib.mod250.chat.client.service;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import no.hib.mod250.chat.client.model.Model;

import com.google.gwt.user.client.rpc.RemoteService;

public interface ChatService extends RemoteService {

	@SuppressWarnings("serial")
	public static class UnauthorizedException extends Exception {
	}

	@SuppressWarnings("serial")
	public static class IllegalMessageException extends Exception {
	}

	@SuppressWarnings("serial")
	public static class Result implements Serializable {

		protected Model.UserAdmin user = null;
		protected List<Model.User> users = new ArrayList<Model.User>();
		protected Model.MessageList messages = new Model.MessageList();
		protected List<Model.Action> actions = new ArrayList<Model.Action>();
		protected long lastUpdated = 0L;

		public Result() {
		}

		public Model.UserAdmin getUser() {
			return user;
		}

		public void setUser(Model.UserAdmin user) {
			this.user = user;
		}

		public List<Model.User> getUsers() {
			return users;
		}

		public void setUsers(List<Model.User> users) {
			this.users = users;
		}

		public List<Model.Action> getActions() {
			return actions;
		}

		public void setActions(List<Model.Action> actions) {
			this.actions = actions;
		}

		public Model.MessageList getMessages() {
			return messages;
		}

		public void setMessages(Model.MessageList messages) {
			this.messages = messages;
		}

		public long getLastUpdated() {
			return lastUpdated;
		}

		public void setLastUpdated(long lastUpdated) {
			this.lastUpdated = lastUpdated;
		}

	}

	public ChatService.Result doInitialize();

	public ChatService.Result doUserAvailable(long lastUpdate)
			throws UnauthorizedException;

	public void doUserBusy() throws UnauthorizedException;

	public void doUserOffline() throws UnauthorizedException;

	public ChatService.Result doMessageNew(long lastUpdate, String message)
			throws UnauthorizedException, IllegalMessageException;

	public ChatService.Result doMessageDelete(long lastUpdate, long id)
			throws UnauthorizedException, IllegalMessageException;

	public ChatService.Result doMessagesDelete(long lastUpdate) throws UnauthorizedException;

	public ChatService.Result doUpdate(long lastUpdate);

}
